﻿function removeOptionSelected(id)
{
  var elSel = document.getElementById(id);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

function appendOption(id1,id2)
{
	for(i=0;i<document.getElementById(id1).options.length;i++){
		if(document.getElementById(id1).options[i].selected){
			title=document.getElementById(id1).options[i].text;	
			giatri=document.getElementById(id1).options[i].value;
			addOption(id2,giatri,title);
		}
	}
	removeOptionSelected(id1);
}
function addOption(id2,giatri,title){
	checkthemmoi=1;
	for(j=0;j<document.getElementById(id2).options.length;j++){
		if(document.getElementById(id2).options[j].value==giatri){
			checkthemmoi=0;
			break;
		}
	}
	if(checkthemmoi==1){
		var elOptNew 		= document.createElement('option');
		elOptNew.text 		= title;
		elOptNew.title		= title;
		elOptNew.value 	= giatri;
		var elSel 			= document.getElementById(id2);
		 try {
			 elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		 }
		 catch(ex) {
			elSel.add(elOptNew); // IE only
		 }
	}
}
function selectAll(id){
	for(i=0;i<document.getElementById(id).options.length;i++){
		document.getElementById(id).options[i].selected=true;
	}
}
function removeOptionLast()
{
  var elSel = document.getElementById('room_select');
  if (elSel.length > 0)
  {
    elSel.remove(elSel.length - 1);
  }
}